//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

//====================================================
// Created     : 2004-1-4
// Author      : Fan Dian
// Description : Some test functions for kernel debug
//====================================================

#include <core.h>
#include <../core/kdbs/kdbs.h>

#ifndef _RELEASE

const int_t C_BREAKNUM = 1000;

EXTERN bool_t g_bInited;

EXTERN struct Z0BREAK g_arrZ0break[C_BREAKNUM];
EXTERN struct Z0BREAK *g_pZ0breakAvail;
EXTERN struct Z0BREAK *g_pZ0breakList;

#endif // #ifndef _RELEASE

//====================================================
// Description  : Test Kernel Debug Initialization
// Parameters   : None
// Return       : None
//====================================================
inline void TestKdb()
{
#ifndef _RELEASE
    // print the status of kdb
    kprintf("g_bInited(kernel debug initialized) = %s\n", \
        g_bInited ? "true" : "false");

    // print the status of current active breakpoints
    uint_t nArrSize = C_BREAKNUM;
    uint_t i;
    kprintf("KDB: current breakpoints link: %s\n", \
        g_pZ0breakList? "not null" : "null");

    // check the status of pooled breakpoints link
    for (i = 0; i < nArrSize - 1; i ++) break;
    if ((i == nArrSize - 1) \
        && (g_arrZ0break[nArrSize - 1].next == 0) \
        && (g_pZ0breakAvail == g_arrZ0break)) {
        kprintf("    KDB: Breakpoint link is very well\n");
    }
    else {
        kprintf("!!!ERROR!!! KDB: Breakpoint link is bad\n");
    }
#endif // #ifndef _RELEASE
}
